﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Light.Framework
{
    /// <summary>
    /// 查询分页参数
    /// </summary>
    [Serializable]
    public class PageArgs
    {
        public PageArgs()
        {
            Tag = "";
            PageIndex = 1;
            PageSize = 20;
        }

        /// <summary>
        /// 页码，从1开始
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页记录数
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalResults { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages
        {
            get
            {
                PageIndex = TotalResults > 0 ? 1 : 0;
                int totalPages = TotalResults / PageSize;

                if (TotalResults % PageSize != 0)
                {
                    totalPages++;
                }

                return totalPages;
            }
        }

        /// <summary>
        /// 备注字段
        /// </summary>
        public string Tag { get; set; }
    }
}
